namespace Management.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class CreateTableSliceQualityAndWaterQuality : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.SliceQualities",
                c => new
                    {
                        SliceQualityID = c.Int(nullable: false, identity: true),
                        DocNum = c.Int(nullable: false),
                        WaterQualityID = c.Int(nullable: false),
                        Number = c.Int(nullable: false),
                        Created_at = c.DateTime(nullable: false),
                        Updated_at = c.DateTime(nullable: false),
                    })
                .PrimaryKey(t => t.SliceQualityID)
                .ForeignKey("dbo.WaterQualities", t => t.WaterQualityID, cascadeDelete: true)
                .Index(t => t.WaterQualityID);
            
            CreateTable(
                "dbo.WaterQualities",
                c => new
                    {
                        WaterQUalityID = c.Int(nullable: false, identity: true),
                        isQualified = c.Int(nullable: false),
                        Type = c.String(nullable: false),
                        Rank = c.String(nullable: false),
                        RankCode = c.String(nullable: false),
                        Name = c.String(nullable: false),
                        EnglishName = c.String(nullable: false),
                        sort = c.Int(nullable: false),
                        IsDisabled = c.Int(nullable: false),
                        IsWorkable = c.Int(nullable: false),
                        Created_at = c.DateTime(nullable: false),
                        Updated_at = c.DateTime(nullable: false),
                    })
                .PrimaryKey(t => t.WaterQUalityID);
            
            AddColumn("dbo.SiliconCuttings", "SliceQualityID", c => c.Int(nullable: true));
            CreateIndex("dbo.SiliconCuttings", "SliceQualityID");
            AddForeignKey("dbo.SiliconCuttings", "SliceQualityID", "dbo.SliceQualities", "SliceQualityID", cascadeDelete: true);
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.SiliconCuttings", "SliceQualityID", "dbo.SliceQualities");
            DropForeignKey("dbo.SliceQualities", "WaterQualityID", "dbo.WaterQualities");
            DropIndex("dbo.SiliconCuttings", new[] { "SliceQualityID" });
            DropIndex("dbo.SliceQualities", new[] { "WaterQualityID" });
            DropColumn("dbo.SiliconCuttings", "SliceQualityID");
            DropTable("dbo.WaterQualities");
            DropTable("dbo.SliceQualities");
        }
    }
}
